home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1323 / grep32.doc next >
Text File  |  1993-10-06  |  5KB  |  118 lines

  1. grep32.doc    Version 1.0.0    October 7, 1993
  2.  
  3. After seeing numerous postings to the net querying the existence of "grep"
  4. for the NT platform I decided to "port" a version of it to "32 bit land".
  5.  
  6. grep32.exe is based on a version of grep which was originally ported to
  7. the pdp 11 (DECUS C).  I cleaned up the code and ported it to MSC 5.1.
  8. I added couple of more modifications and have produced the 32 bit version
  9. for the Windows NT command line.  Granted, this is a "quick port" and has
  10. no graphical user interface.  I would like to give it one as soon as I
  11. get some more time to play with it.
  12.  
  13. I believe that this version has all the functionality of the UNIX version
  14. plus a couple more things I threw in.
  15.  
  16. Please send questions comments, suggestions to:
  17.  
  18.     
  19.             Marc Geist
  20.             Dept. 469
  21.             AT&T Information Systems
  22.             1200 w. 120th Ave.
  23.             Westminster, CO 80234-2795
  24.  
  25.             303-538-2653
  26.             mag@dwgrc5.dw.att.com
  27.  
  28.  
  29. Quick overview of the grep32 command line and regular expression syntax:
  30.  
  31. Usage:  grep [-bcilmnsvq? -dnnn] "pattern" file1 file2 ... [>ofile] [>>ofile]
  32.  
  33.     Options:
  34.       b    Each line is preceded by the block number of the file
  35.            in which it is found. (based on 512 byte blocks).
  36.       c    Only print the number of lines matched.
  37.       i    Ignore the case of each character while matching.
  38.       l    Only list the names of files containing a match
  39.            (or a nonmatch if 'v' option is selected).
  40.       m    Program prompts for search string (helps in search for ' and ")
  41.       n    Precede each printed line by its relative line
  42.            number in the file.
  43.       s    Suppress all error messages produced by non-readable files.
  44.       v    All lines but those matching are printed.
  45.       q    Suppress header information in output.
  46.       dnnn    Dump nnn lines of text including the string match line.
  47.       >    Will create new version of output file.
  48.      >>    Will append to output file if it exists or will
  49.            create it if it does not exist.
  50.       ?    Print this message plus more detailed information on
  51.            options and pattern matching.
  52.  
  53. If the 'm' option is specified, no search pattern is expected on command line.
  54.  
  55. Wildcards in specified file names are supported via the functionality
  56. provided by \MSVCNT\LIB\SETARGV.OBJ (read your MSC documentaion for a
  57. description of this).
  58.  
  59. Options can be placed anywhere on the command line and they are additive.
  60. The first occurance of an argument not preceded by '-' will be acknowledged
  61. as the pattern string to be searched for unless the 'm' option has been
  62. specified.  Any other arguments not preceded by '-' will be taken as
  63. filenames.  The minimum number of arguments must contain at least a pattern
  64. string and a filename or the 'm' option and a filename.  If no options are
  65. specified the default condition is an exact pattern search in the filename(s)
  66. specified with all matching lines printed to the screen.
  67.  
  68. How to construct special regular expression search patterns:
  69.  
  70.   Special Characters:
  71.  
  72.         *  Wildcard that matches any character or number of characters.
  73.         .  (period) matches any one character.
  74.         ^  (caret) at the beginning of a pattern constrains the pattern
  75.            to a match the initial segment of a line.
  76.         $  (currency sign) at the end of a pattern constrains the
  77.            pattern to a match the final segment of a line.
  78.         [  Used to "begin-block" a string of characters for special one-
  79.            character matches.
  80.         ]  Used to "end-block" a string of characters for special one-
  81.            character matches.
  82.         \  Backslash followed by any special character will match that
  83.            special character (i.e. "\[" will match the character '[').
  84.  
  85.   Special Constructs:
  86.  
  87.         [str]  A non-empty string of characters enclosed by square brackets
  88.            will match any one character in the string.
  89.        [^str]  A non-empty string of characters enclosed by square brackets
  90.            and preceded by a "caret" will match any character except
  91.            the characters in the string.
  92.         -  (hyphen) may be used to indicate a range of consecutive
  93.            ascii characters (i.e [0-9] = [0123456789].  The '-' loses
  94.            its special meaning if it occurs after an initial '^' or is
  95.            located last in the string.
  96.             \{m\}
  97.            \{m,\}
  98.           \{m,n\}  A one character expression followed by \{m\}, \{m,\}, or
  99.            \{m,n\} is an expression that matches a range of occurances
  100.            of the one character expression.  Values of m and n must be
  101.            non-negative integers less than 256.  \{m\} matches exactly
  102.            m occurances, \{m,\} matches at least m occurances, and
  103.            \{m,n\} matches any range of occurances between m and n
  104.            inclusive.
  105.    \(expression\)  An expression enclosed between \( and \) is an expression
  106.            that matches whatever the unadorned expression matches.
  107.            \n  The expression \n matches the same string of characters as
  108.            was matched by an expression enclosed between \( and \)
  109.            earlier in the same expression.  n is a digit and the sub-
  110.            expression specified is associated with the n-th
  111.            occurance of \( counting from the left.  For example the
  112.            expression: \(test\).*\1 matches a line containing at least
  113.            two occurances of the string "test".
  114.  
  115.     A concatenation of expressions is an expression that matches the con-
  116.     catenation of the strings matched by each component of the expression.
  117.  
  118.